Maple 2023 Questions and Posts

These are Posts and Questions associated with the product, Maple 2023

I this code, I do by my hand (x - ptA[1])^2 + (y - ptA[2])^2 + (z - ptA[3])^2 = r^2;

restart;
with(geom3d);
ptA := coordinates(point(A, 1, -4, 3));
point(B, -3, 2, 5);
r := distance(A, B);
Equation(sphere(S, [A, r], [x, y, z]));
(x - ptA[1])^2 + (y - ptA[2])^2 + (z - ptA[3])^2 = r^2;

When I used Equation(sphere(S, [A, r], [x, y, z])); I got


Is there a function to convert Equation(sphere(S, [A, r], [x, y, z])); to get the result

I have this code

restart;
with(geometry);
with(StringTools);
interface(worksheetdir);
currentdir(%);
toX := e -> latex(e, 'output' = 'string');
s := toX(e);
s := StringTools:-Substitute(s, "[", "(");
s := StringTools:-Substitute(s, "]", ")");
s := StringTools:-SubstituteAll(s, ",", ";");
s := StringTools:-SubstituteAll(s, "\\frac", "\\dfrac");
s := StringTools:-SubstituteAll(s, "-\\infty", "#@#");
s := StringTools:-SubstituteAll(%, "\\infty", "+\\infty");
s := StringTools:-SubstituteAll(%, "#@#", "-\\infty");
printf("\\documentclass[12pt]{article}\n");
printf("\\usepackage{amsmath,amssymb}\n");
printf("\\usepackage{enumitem}\n");
printf("\\begin{document}\n\n");
f := x -> (x^2 + 4*x + 7)/(x + 1);
df := simplify(diff(f(x), x));
cuctri := sort([solve(df = 0, x)], key = evalf);
g := simplify(diff(df, x));
xcd := rhs(solve([df = 0, g(x) < 0], x)[1]);
xct := rhs(solve([df = 0, 0 < g(x)], x)[1]);
ycd := simplify(f(xcd));
yct := simplify(f(xct));
mycd := coordinates(point(A, xcd, ycd));
myct := coordinates(point(B, xct, yct));
L := [cat("Let a function be given: $y = ", toX(f(x)), "$."), cat("Its derivative is: $y' = ", toX(df), "$."), cat("The maximum point of the graph  $ ", toX(mycd), "$.")];

printf("\\begin{enumerate}[label=\\arabic*)]\n");
for item in L do
    printf("\\item %s\n", item);
end do;
printf("\\end{enumerate}\n\n");

I got

\documentclass[12pt]{article}
\usepackage{amsmath,amssymb}
\usepackage{enumitem}
\begin{document}

\begin{enumerate}[label=\arabic*)]
\item Let a function be given: $y = \frac{x^{2}+4 x +7}{x +1}$.
\item Its derivative is: $y' = \frac{x^{2}+2 x -3}{\left(x +1\right)^{2}}$.
\item The maximum point of the graph  $ [-3, -2]$.
\end{enumerate}

I want to $ (-3; -2)$, not $ [-3, -2]$. How can I make the function toX apply to the whole document?

I tried

restart;
with(geometry);
with(StringTools);
interface(worksheetdir);
currentdir(%);
toX := proc(e) local s; s := latex(e, 'output' = 'string'); s := Substitute(s, "[", "("); s := Substitute(s, "]", ")"); s := SubstituteAll(s, ",", ";"); s := SubstituteAll(s, "\\frac", "\\dfrac"); s := SubstituteAll(s, "-\\infty", "#@#"); s := SubstituteAll(s, "\\infty", "+\\infty"); s := SubstituteAll(s, "#@#", "-\\infty"); return s; end proc;
printf("\\documentclass[12pt]{article}\n");
printf("\\usepackage{amsmath,amssymb}\n");
printf("\\usepackage{enumitem}\n");
printf("\\begin{document}\n\n");
f := x -> (x^2 + 4*x + 7)/(x + 1);
df := simplify(diff(f(x), x));
cuctri := sort([solve(df = 0, x)], key = evalf);
g := simplify(diff(df, x));
xcd := rhs(solve([df = 0, g(x) < 0], x)[1]);
xct := rhs(solve([df = 0, 0 < g(x)], x)[1]);
ycd := simplify(f(xcd));
yct := simplify(f(xct));
mycd := coordinates(point(A, xcd, ycd));
myct := coordinates(point(B, xct, yct));
L := [cat("Let a function be given: $y = ", toX(f(x)), "$."), cat("Its derivative is: $y' = ", toX(df), "$."), cat("The maximum point of the graph  $ ", toX(mycd), "$.")];
printf("\\begin{enumerate}[label=\\arabic*)]\n");
for item in L do
    printf("\\item %s\n", item);
end do;
printf("\\end{enumerate}\n\n");

and got the 

 

\begin{enumerate}[label=\arabic*)]
\item Let a function be given: $y = \dfrac{x^{2}+4 x +7}{x +1}$.
\item Its derivative is: $y' = \dfrac{x^{2}+2 x -3}{\left(x +1\right)^{2}}$.
\item The maximum point of the graph  $ (-3; -2)$.
\end{enumerate}

 

I want to change all `\infty` with `+\infty`. I tried

s := StringTools:-SubstituteAll(s, "\\infty", "+\\infty")

Then,  `-\\infty` to `- + \\infty`. How can I replace \infty with +\infty but keep -\infty unchanged?

I want to write the equation of the line in the form a*x + b*y + c=0, with igcd(a,b,c)=1 of this code

restart;
with(geometry);
point(A, 2, -3);
point(B, -1, 6);
sort(Equation(line(d, [A, B], [x, y])));

I tried by hand

-1/3*sort(Equation(line(d, [A, B], [x, y])))

How can I get the result 3x + y - 3=0 automatically?

PS. I tried and get the answer 3x + y - 3 =0.

restart;
with(geometry);
point(A, 2, -3);
point(B, -1, 6);
eq := sort(Equation(line(AB, [A, B], [x, y])));
k := igcd(coeff(lhs(eq), x), coeff(lhs(eq), y));
sort(eq*sign(coeff(lhs(eq), x))/k);

 

I am using S := sort([sqrt(x2), sqrt(y2), sqrt(z2)]);

restart;
n := 0:
L := []:

for a from 3 to 100 do
    for b from 3 to a do
        c2 := a^2 - a*b + b^2;
        c := isqrt(c2);
        if c^2 = c2 then
            if c < a + b and a < b + c and b < c + a then
                if igcd(a, b, c) = 1 then
                    x2 := (-a^2 + b^2 + c^2)/2;
                    y2 := (a^2 - b^2 + c^2)/2;
                    z2 := (a^2 + b^2 - c^2)/2;
                    if 0 < x2 and 0 < y2 and 0 < z2 then
                        S := sort([sqrt(x2), sqrt(y2), sqrt(z2)]);
                        x := S[1]; 
                        y := S[2]; 
                        z := S[3];
                        n := n + 1;
                        L := [op(L), [x, y, z, sqrt(x^2 + y^2), sqrt(y^2 + z^2), sqrt(x^2 + z^2)]];
                    end if;
                end if;
            end if;
        end if;
    end do;
end do;

n;
L;
 

But I get the result. How can I get the correct result of sort? 

How Maple 2023 displays new results with old results together

I have a random variable called Y1, which looks like the following: Y1 = 2*sqrt(1 - x^2)/Pi, on the (-1 < x < 1) interval. This "semicircle" integrates to 1, like other random variables. Random variable Y2 is the same as Y1 above. I want to find the random variable Z, which is equal to the absolute difference of two random variables Y1 and Y2. In other words, I want to find Z = |Y1 - Y2|. Via simulation, I know that |Y1 - Y2| takes on a logrithmic form, but I need to get a mathematical solution of this.

DrawGraph(Graph({[{1, 2}, 0.7462761011], [{2, 3}, 0.8190708767], [{2, 4}, 0.6810933318], [{4, 5}, 0.7451261104], [{4, 23}, 0.6746390886], [{5, 6}, 0.7231256359], [{6, 7}, 0.6775594149], [{6, 10}, 0.7019893588], [{7, 8}, 0.6618796622], [{7, 9}, 0.6623496808], [{8, 9}, 0.6688297164], [{10, 11}, 0.7092623872], [{10, 22}, 0.7112560850], [{11, 12}, 0.7098970677], [{12, 13}, 0.7108845941], [{12, 19}, 0.7092202631], [{13, 14}, 0.6734297238], [{13, 18}, 0.6767541419], [{14, 15}, 0.6466191140], [{15, 16}, 0.6773709292], [{16, 17}, 0.6780410682], [{17, 18}, 0.6468993314], [{19, 20}, 0.7444847640], [{19, 21}, 0.7192676187], [{21, 22}, 0.7167453581], [{22, 23}, 0.6726943362], [{23, 24}, 0.8156746068]}), layout = spring)

DrawGraph and save that as 300 dpi png increase edge length so that the edge weight show up How do the edge are small sized and weights overlap and and are not neatly seen in the middle of edge without overlap kind help with a code to correct this

I am interested in determining the density function which results from multiplying two random variables.  I have read about the Mellin Transformation, but I just end up confused.  I have two random variables:  f[1], which is nonzero on the 0 < t < 2 interval, and f[2], which is nonzero on the 0 < t < 1 interval.  Of course, both of these random variables sum to one when evaluated.

Any thoughts on how I can obtain the density function for this?  My work is below.

restart

with(Statistics)

f[1] := piecewise(t <= 0, 0, 0 < t and t < 2, 1/(Pi*sqrt(1-(1-t)^2)), t >= 2, 0)

piecewise(t <= 0, 0, 0 < t and t < 2, 1/(Pi*(1-(1-t)^2)^(1/2)), 2 <= t, 0)

f[2] := piecewise(t <= 0, 0, 0 < t and t < 1, 2*t, t >= 1, 0)

piecewise(t <= 0, 0, 0 < t and t < 1, 2*t, 1 <= t, 0)


Download Inquiry.mw

Hello everyone,
Could someone tell me how to insert an entry (empty cell) between two already filled entries or above an already filled entry in Document Mode?

Oliveira

I am learning how to use Maple for solving single and systems of linear PDE's using the Laplace transform (LT)method so the resulting solution in s space can be used to generate the moments of the resulting probability distribution.

When I take the LT of a term such as Uxx(t,x), I expect a second order ordinary derivative. Instead, it shows the Laplace transform operator.

Here is a simple test code  

with(inttrans):

with(DEtools):

rhs_pde := diff(u(x, t), x, x);

laplace_rhs_pde := laplace(rhs_pde, t, s);

I constructed a density function, and I am certain it shows me what I want.  The problem I am having is parsing the Elliptic functions. Is there a way to "get rid" of the ones I don't want or need.

I generated a plot of the function -- the plot tells me what I expected based on simulation. I need to know if there is a way to express the density function (y) as a function of t and without the elliptic functions..  Even a numerical solution would be fine.

I assume the denomenator term is correct. I also assume that I don't need complex values. My input file is below.

Basics.mw

I have a piecewise density function (f).  I am trying to find the median value.

I have tried the Median function and the Percentile function, but neither work for me.  I am not sure why.

I have also tried to integrate the density function on the (0,x) interval such that the area under the curve is 1/2 and then solve for x.  This works for simple problems, but not the one attached.

There is something very simple that I'm not doing, but I am not sure what.

restart

kernelopts(version)

`Maple 2023.2, X86 64 WINDOWS, Nov 24 2023, Build ID 1762575`

(1)

with(Statistics)

 

(2)

f := 2*t*piecewise(t <= 0, 0, t <= 1, t^2+Pi-4*t, t <= sqrt(2), -(sqrt(t^2-1)*t^2+2*sqrt(t^2-1)*arcsin((t^2-2)/t^2)-4*t^2+2*sqrt(t^2-1)+4)/sqrt(t^2-1), sqrt(2) < t, 0)

2*t*piecewise(t <= 0, 0, t <= 1, t^2+Pi-4*t, t <= 2^(1/2), -((t^2-1)^(1/2)*t^2+2*(t^2-1)^(1/2)*arcsin((t^2-2)/t^2)-4*t^2+2*(t^2-1)^(1/2)+4)/(t^2-1)^(1/2), 2^(1/2) < t, 0)

(3)

plot(f, t = 0 .. sqrt(2))

 

Median(f)

2*t*piecewise(t <= 0, 0, t <= 1, t^2+Pi-4*t, t <= 2^(1/2), -((t^2-1)^(1/2)*t^2+2*(t^2-1)^(1/2)*arcsin((t^2-2)/t^2)-4*t^2+2*(t^2-1)^(1/2)+4)/(t^2-1)^(1/2), 2^(1/2) < t, 0)

(4)

Percentile(f, 50)

2*t*piecewise(t <= 0, 0, t <= 1, t^2+Pi-4*t, t <= 2^(1/2), -((t^2-1)^(1/2)*t^2+2*(t^2-1)^(1/2)*arcsin((t^2-2)/t^2)-4*t^2+2*(t^2-1)^(1/2)+4)/(t^2-1)^(1/2), 2^(1/2) < t, 0)

(5)

myMedian := solve(int(f, t = 0 .. x) = 1/2, x)

Warning, solutions may have been lost

 

(6)

NULL

Download Median.mw

I am trying to find the standard deviation for a piecewise density function (f).  The interval is (0, sqrt(3))  I am convinced the density function is what I want.  I calculate the expected value of the density function (evE) and the answer is correct -- about 0.66145

When I try to calculate the standard deviation (stdE), I get an answer that is "off" by a large degree.  Via simulating values, I should get a value of about 0.24936.  Each time I "re-run" the calculation, I get varying results, all of which are "off" by a large degree.

I am only guessing, but my integration function might be missing some sort of assumption and/or option.

My work is attached.  Does anyone know what I am doing wrong?

restart

with(Statistics)

f := -t*piecewise(t <= 0, 0, t <= 1, t*(t^3+6*Pi*t-8*t^2-4*Pi), t <= sqrt(2), -(2*(4*t^2*sqrt(t^2-1)*arcsin((t^2-2)/t^2)+4*t^2*arctan(sqrt(t^2-1))*sqrt(t^2-1)+(t^4+(2*Pi+3)*t^2-4*t*Pi+3*Pi-1/2)*sqrt(t^2-1)-8*t^4+4*t^2+4))/sqrt(t^2-1), t <= sqrt(3), (8*arctan((t^3+t^2-3*t-1)/(sqrt(t^2-2)*(t^3-t^2-t-1)))*t*sqrt(t^2-2)-4*arccot((t^2-t-1)/sqrt(t^2-2))*t^2*sqrt(t^2-2)+4*t*sqrt(t^2-2)*(t+2)*arctan((t^2+t-1)/sqrt(t^2-2))+(8*t^2-4)*sqrt(t^2-2)*arcsin((t^2-3)/(t^2-1))+16*arcsin(sqrt(t^2-2)/sqrt(t^2-1))*sqrt(t^2-2)-16*arcsin(1/sqrt(t^2-1))*sqrt(t^2-2)+((t^2+5)*sqrt(t^2-2)-8*t^2+16)*(t^2+1))/sqrt(t^2-2), sqrt(3) < t, 0)

-t*piecewise(t <= 0, 0, t <= 1, t*(t^3+6*Pi*t-8*t^2-4*Pi), t <= 2^(1/2), -2*(4*t^2*(t^2-1)^(1/2)*arcsin((t^2-2)/t^2)+4*t^2*arctan((t^2-1)^(1/2))*(t^2-1)^(1/2)+(t^4+(2*Pi+3)*t^2-4*t*Pi+3*Pi-1/2)*(t^2-1)^(1/2)-8*t^4+4*t^2+4)/(t^2-1)^(1/2), t <= 3^(1/2), (8*arctan((t^3+t^2-3*t-1)/((t^2-2)^(1/2)*(t^3-t^2-t-1)))*t*(t^2-2)^(1/2)-4*arccot((t^2-t-1)/(t^2-2)^(1/2))*t^2*(t^2-2)^(1/2)+4*t*(t^2-2)^(1/2)*(t+2)*arctan((t^2+t-1)/(t^2-2)^(1/2))+(8*t^2-4)*(t^2-2)^(1/2)*arcsin((t^2-3)/(t^2-1))+16*arcsin((t^2-2)^(1/2)/(t^2-1)^(1/2))*(t^2-2)^(1/2)-16*arcsin(1/(t^2-1)^(1/2))*(t^2-2)^(1/2)+((t^2+5)*(t^2-2)^(1/2)-8*t^2+16)*(t^2+1))/(t^2-2)^(1/2), 3^(1/2) < t, 0)

(1)

plot(f, t = 0 .. sqrt(3))

 

evE := simplify(int(t*f, t = 0 .. sqrt(3)))

(1/105)*(294*(2^(1/2)-3/2)*(-2+3^(1/2))*ln(1+2^(1/2))+168*(2^(1/2)-3/2)*(-2+3^(1/2))*ln(1+3^(1/2))-252*(2^(1/2)-3/2)*(-2+3^(1/2))*arccoth(2^(1/2))+((-14*Pi-84*ln(2)-19)*3^(1/2)+28*Pi+168*ln(2)+50)*2^(1/2)+(21*Pi+126*ln(2)+20)*3^(1/2)-42*Pi-252*ln(2)-58)/((2*2^(1/2)-3)*(-2+3^(1/2)))

(2)

evalf(evE)

.6617071838

(3)

stdE := simplify(sqrt(int(f*(t-evE)^2, t = 0 .. sqrt(3))))

(1/210)*(-4808607312140100*(2^(1/2)-3880899/2744210)*(3^(1/2)-70226/40545)*ln(1+2^(1/2))^2+(-5495551213874400*(2^(1/2)-3880899/2744210)*(3^(1/2)-70226/40545)*ln(1+3^(1/2))+8243326820811600*(2^(1/2)-3880899/2744210)*(3^(1/2)-70226/40545)*arccoth(2^(1/2))+((457962601156200*Pi+2747775606937200*ln(2)+631290043332900)*3^(1/2)-793214493249360*Pi-4759286959496160*ln(2)-1093426429714584)*2^(1/2)+(-647656921614780*Pi-3885941529688680*ln(2)-892778941072368)*3^(1/2)+1121774694224184*Pi+6730648165345104*ln(2)+1546338486359352)*ln(1+2^(1/2))-1570157489678400*(2^(1/2)-3880899/2744210)*(3^(1/2)-70226/40545)*ln(1+3^(1/2))^2+(4710472469035200*(2^(1/2)-3880899/2744210)*(3^(1/2)-70226/40545)*arccoth(2^(1/2))+((261692914946400*Pi+1570157489678400*ln(2)+360737167618800)*3^(1/2)-453265424713920*Pi-2719592548283520*ln(2)-624815102694048)*2^(1/2)+(-370089669494160*Pi-2220538016964960*ln(2)-510159394898496)*3^(1/2)+641014110985248*Pi+3846084665911488*ln(2)+883621992205344)*ln(1+3^(1/2))-3532854351776400*(2^(1/2)-3880899/2744210)*(3^(1/2)-70226/40545)*arccoth(2^(1/2))^2+(((-392539372419600*Pi-2355236234517600*ln(2)-541105751428200)*3^(1/2)+679898137070880*Pi+4079388822425280*ln(2)+937222654041072)*2^(1/2)+(555134504241240*Pi+3330807025447440*ln(2)+765239092347744)*3^(1/2)-961521166477872*Pi-5769126998867232*ln(2)-1325432988308016)*arccoth(2^(1/2))+((-392539372419600*ln(2)^2+(-130846457473200*Pi-180368583809400)*ln(2)-10903871456100*Pi^2-30061430634900*Pi+1205966071986042)*3^(1/2)+679898137070880*ln(2)^2+(226632712356960*Pi+312407551347024)*ln(2)+18886059363080*Pi^2+52067925224504*Pi-2088794509063308)*2^(1/2)+(555134504241240*ln(2)^2+(185044834747080*Pi+255079697449248)*ln(2)+15420402895590*Pi^2+42513282908208*Pi-1705493574764511)*3^(1/2)-961521166477872*ln(2)^2+(-320507055492624*Pi-441810996102672)*ln(2)-26708921291052*Pi^2-73635166017112*Pi+2954001523727854)^(1/2)*(5*2^(1/2)-7)*(-5+3*3^(1/2))/((70*2^(1/2)-99)*(15*3^(1/2)-26)*(-2+3^(1/2))*(4*3^(1/2)-7)*(12*2^(1/2)-17)*(2*2^(1/2)-3))

(4)

evalf(stdE)

7031348.295

(5)
 

NULL

Download StdE.mw

1 2 3 4 5 6 7 Last Page 1 of 32